<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui"
                template="../templates/principal.xhtml">
<!--
    <ui:define name="head">
        <style type="text/css">
            .ui-column-filter {
                width: 280px !important;
            } 
            .ui-column-filter ui-widget {
                width: 280px !important;
            }
            .ui-column-filter ui-widget ui-state-default {
                width: 280px !important;
            }
            .ui-column-filter ui-widget ui-state-default ui-corner-left {
                width: 280px !important;
            }

        </style>
    </ui:define>
-->
    <ui:define name="content" id="content">
        <h:form id="frmProposta">
            <p:panel id="panel" header="Bem Vindo a Elaboração da Proposta">
                <p:growl id="messages" life="5000" />

                <p:dataTable id="tabProposta" widgetVar="wtabProposta" var="proposta" value="#{propostaBean.lazyModel}" 
                             lazy="true" paginator="true" rows="20" paginatorPosition="top" editable="true"
                             emptyMessage="Nenhum Registro Retornado ..." filterEvent="enter" resizableColumns="true">

                    <f:facet name="header">
                        STATUS: Alteração do Status das Propostas
                    </f:facet>

                    <p:ajax event="rowEdit" listener="#{propostaBean.onEdit}" update=":frmProposta:tabProposta :frmProposta:messages" />

                    <p:column headerText="No.Proposta" sortBy="#{proposta.numProposta}" filterBy="#{proposta.numProposta}">
                        <h:outputText value="#{proposta.numProposta}" />
                    </p:column>

                    <p:column headerText="No. O.S." sortBy="#{proposta.numOs}" filterBy="#{proposta.numOs}">
                        <h:outputText value="#{proposta.numOs}" />
                    </p:column>

                    <p:column headerText="EMPREENDIMENTO" sortBy="#{proposta.idEmpreendimento.dscEmpreendimento}" filterBy="#{proposta.idEmpreendimento.dscEmpreendimento}">
                        <h:outputText value="#{proposta.idEmpreendimento.dscEmpreendimento}" />
                    </p:column>

                    <p:column headerText="ASSUNTO" sortBy="#{proposta.dscProposta}" filterBy="#{proposta.dscProposta}">
                        <h:outputText value="#{proposta.dscProposta}" />
                    </p:column>

                    <p:column headerText="EMPRESA" sortBy="#{proposta.idEmpresa.nomEmpresa}" filterBy="#{proposta.idEmpresa.nomEmpresa}">
                        <h:outputText value="#{proposta.idEmpresa.nomEmpresa}" />
                    </p:column>


                    <p:column headerText="FANTASIA/SOBRENOME" sortBy="#{proposta.idCliente.nomFantasia}" filterBy="#{proposta.idCliente.nomFantasia}">
                        <h:outputText value="#{proposta.idCliente.nomFantasia}" />
                    </p:column>

                    <p:column headerText="STATUS" sortBy="#{proposta.tipStatus}" filterBy="#{proposta.tipStatus}"  
                              filterOptions="#{propostaBean.tipStatusOptions}" filterMatchMode="exact" style="width: 20%; text-align: left;">

                        <p:cellEditor>

                            <f:facet name="output">
                                <h:outputText value="#{proposta.dscStatus}" style="width: 100%; text-align: left; "/>
                            </f:facet>

                            <f:facet name="input">
                                <p:selectOneMenu value="#{propostaBean.tipStatusValue}" style="width:100%;" height="350">
                                    <f:selectItems value="#{propostaBean.tipStatusOptions}" var="status" itemLabel="#{status}" itemValue="#{status}" />
                                </p:selectOneMenu>
                            </f:facet>

                        </p:cellEditor>

                    </p:column>

                    <p:column style="width:2%;">
                        <p:rowEditor />
                    </p:column>
                </p:dataTable>
            </p:panel>

        </h:form>
    </ui:define>
</ui:composition>